
USE [RealtorPortal]
GO
-- ================================================
-- Template generated from Template Explorer using:
-- Create Procedure (New Menu).SQL
--
-- Use the Specify Values for Template Parameters 
-- command (Ctrl-Shift-M) to fill in the parameter 
-- values below.
--
-- This block of comments will not be included in
-- the definition of the procedure.
-- ================================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	<Description,,>
-- =============================================


------------------------------------------------------
------------------------------------------------------
------------------------------------------------------
------------------------------------------------------
------------------------------------------------------
CREATE PROC [dbo].[sp_addCate]
@CategoryName as varchar(200),
@Description as varchar(max),
@IsActive as bit
AS

BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

    Insert into Categories(CategoryName, [Description], IsActive)
VALUES(@CategoryName,@Description,@IsActive)

END
GO


------------------------------------------------------
------------------------------------------------------
------------------------------------------------------
------------------------------------------------------
------------------------------------------------------
CREATE PROC [dbo].[sp_updateCate]

@OldCategoryId as int,
@CategoryName as varchar(200),
@Description as varchar(max),
@IsActive as bit
ASd

BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

    Update Categories set CategoryName = @Category   ,@Description,@IsActive)

END
GO


------------------------------------------------------
------------------------------------------------------
------------------------------------------------------
------------------------------------------------------
------------------------------------------------------
CREATE PROCEDURE [dbo].[sp_deleteCate]
	-- Add the parameters for the stored procedure here
	@CategoryId as int
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

    -- Insert statements for procedure here
	delete from	
		Categories
	where
		CategoryId = @CategoryId
END
GO

------------------------------------------------------
------------------------------------------------------
------------------------------------------------------
------------------------------------------------------
------------------------------------------------------
CREATE PROCEDURE [dbo].[sp_addNews] 
	-- Add the parameters for the stored procedure here
	@AdminId as int,
	@Title as varchar(max),
	@Content as text,
	@NewsImage as varchar(250),
	@WritedDate as varchar(50)
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

    -- Insert statements for procedure here
	Insert into 
		News(AdminId, Title,Content,NewsImage,WritedDate) 
	values 
		(@AdminId, @Title, @Content, @NewsImage, @WritedDate)
END
GO


------------------------------------------------------
------------------------------------------------------
------------------------------------------------------
------------------------------------------------------
------------------------------------------------------

create PROCEDURE [dbo].[sp_updateNews] 
	-- Add the parameters for the stored procedure here
	@OldNewsId as int,
	@Title as varchar(max),
	@Content as text,
	@NewsImage as varchar(250),
	@WritedDate as varchar(50)
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

    -- Insert statements for procedure here
	Update 
		News
	set 
		Title = @Title,
		Content = @Content,
		NewsImage = @NewsImage,
		WritedDate = @WritedDate
	where
		NewsId = @OldNewsId
END



------------------------------------------------------
------------------------------------------------------
------------------------------------------------------
------------------------------------------------------
------------------------------------------------------
CREATE PROCEDURE [dbo].[sp_deleteNews] 
	-- Add the parameters for the stored procedure here
	@NewsId as int
	
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

    -- Insert statements for procedure here
	Delete from News
	where
		NewsId = @NewsId
END
GO

------------------------------------------------------
------------------------------------------------------
------------------------------------------------------
------------------------------------------------------
------------------------------------------------------

CREATE PROCEDURE [dbo].[sp_addPackage] 
	@PackageName as varchar(100),
	@Price as money,
	@NumOfAds as int,
	@NumOfImg as int,
	@Duration as int,
	@IsActive as bit,
	@IsVip as bit
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

    -- Insert statements for procedure here
	Insert into	
		Packages(PackageName, Price,NumOfAds,NumOfImg,Duration,IsActive,IsVIP)
	values
		(@PackageName,@Price,@NumOfAds,@NumOfImg,@Duration,@IsActive,@IsVip)
	
END
GO


------------------------------------------------------
------------------------------------------------------
------------------------------------------------------
------------------------------------------------------
------------------------------------------------------

CREATE PROCEDURE [dbo].[sp_updatePackage] 

	@OldPackageId as int,
	@PackageName as varchar(100),
	@Price as money,
	@NumOfAds as int,
	@NumOfImg as int,
	@Duration as int,
	@IsActive as bit,
	@IsVip as bit
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

    -- Insert statements for procedure here
	Update 	
		Packages
	set
		PackageName= @PackageName,
		Price= @Price,
		NumOfAds =  @NumOfAds,
		NumOfImg= @NumOfImg,
		Duration = @Duration,
		IsActive = @IsActive,
		IsVIP = @IsVip
	where
		PackageId = @OldPackageId
	
END
GO


------------------------------------------------------
------------------------------------------------------
------------------------------------------------------
------------------------------------------------------
------------------------------------------------------


CREATE PROCEDURE [dbo].[sp_deletePackage] 

	@PackageId as int
	
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

    -- Insert statements for procedure here
	delete from 
		Packages
	where
		PackageId = @PackageId
	
END
GO


/****** Object:  StoredProcedure [dbo].[sp_Get_Categories]    Script Date: 04/29/2013 11:59:23 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

-----------------------------------------------------------------------------------------------------------------------
-- STORE PROCEDURE FOR Categories
create proc [dbo].[sp_Get_News]
as
	begin
		Select * from News		
	end